package util

import java.text.SimpleDateFormat

/**
  * 时间差计算
  */

object TimeUtil {


  def time(time1:String,time2:String): Double = {

    val hour1 =  time1.substring(8,10).toDouble

    val minute1 =  time1.substring(10,12).toDouble

    val second1 =  time1.substring(12,14).toDouble

    val hour2 =  time2.substring(8,10).toDouble

    val minute2 =  time2.substring(10,12).toDouble

    val second2 =  time2.substring(12,14).toDouble

    val time_result = (hour2 - hour1)+(minute2 - minute1)/60+(second2 - second1)/3600

    time_result

  }
  def tranTimeToLong(pattern: String, tm: String): Long = {
    val fm = new SimpleDateFormat(pattern)
    val time = fm.parse(tm).getTime
    time
  }

}

